/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #0c0c2e 0%, #1a1a4a 100%);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Responsive container - adapts to iframe vs full screen */
.game-container {
    position: relative;
    width: 100%;
    height: 450px; /* Default iframe height */
    max-width: 100vw;
    background: radial-gradient(ellipse at center, #1a1a4a 0%, #0c0c2e 100%);
    overflow: hidden;
    border-radius: 8px;
}

/* Full screen detection for new tab */
@media (min-height: 500px) and (min-width: 800px) {
    .game-container {
        height: 90vh;
    }
}

/* Game canvas - main play area */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    cursor: none;
    z-index: 1;
}

/* Game UI overlay */
.game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* Status bar at top */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    border-bottom: 2px solid #4a90e2;
    flex-wrap: wrap;
    gap: 8px;
}

.score-display, .lives-display, .level-display {
    display: flex;
    align-items: center;
    gap: 6px;
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.label {
    font-size: 12px;
    opacity: 0.8;
}

.score {
    color: #ffd700;
    font-size: 16px;
    text-shadow: 0 0 8px #ffd700;
}

.stars {
    display: flex;
    gap: 2px;
}

.star {
    color: #ffd700;
    font-size: 12px;
    animation: sparkle 1s ease-in-out infinite alternate;
}

@keyframes sparkle {
    0% { opacity: 0.5; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1.2); }
}

.hearts {
    display: flex;
    gap: 2px;
}

.heart {
    font-size: 16px;
    transition: all 0.3s ease;
}

.heart.lost {
    opacity: 0.3;
    filter: grayscale(100%);
}

.level {
    color: #4a90e2;
    font-size: 16px;
}

.progress-bar {
    width: 60px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, #4a90e2, #7bb3f0);
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(74, 144, 226, 0.6);
}

/* Question panel */
.question-panel {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border: 2px solid #4a90e2;
    border-radius: 12px;
    padding: 12px 20px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    max-width: 90%;
}

.question-text {
    color: #ffd700;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 4px;
    text-shadow: 0 0 8px #ffd700;
}

.question-meaning {
    color: #ffffff;
    font-size: 14px;
    opacity: 0.9;
}

/* Control buttons */
.controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

.control-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    border: 2px solid rgba(74, 144, 226, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: rgba(74, 144, 226, 0.8);
    border-color: #4a90e2;
    transform: scale(1.1);
}

.control-btn:active {
    transform: scale(0.95);
}

/* Game over screen */
.game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: auto;
}

.game-over-content {
    background: linear-gradient(135deg, #1a1a4a, #2a2a6a);
    border: 3px solid #4a90e2;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
    max-width: 90%;
    min-width: 280px;
}

.game-over-content h2 {
    color: #ffd700;
    font-size: 24px;
    margin-bottom: 16px;
    text-shadow: 0 0 12px #ffd700;
}

.final-score {
    color: white;
    font-size: 18px;
    margin-bottom: 16px;
}

.game-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.game-stats div {
    color: #4a90e2;
    font-size: 14px;
}

.restart-btn, .leaderboard-btn {
    background: linear-gradient(135deg, #4a90e2, #7bb3f0);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    padding: 12px 24px;
    margin: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
    min-width: 120px;
}

.restart-btn:hover, .leaderboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.6);
}

/* Modal styles */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    pointer-events: auto;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a4a, #2a2a6a);
    border: 3px solid #4a90e2;
    border-radius: 16px;
    max-width: 90%;
    max-height: 80%;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 2px solid #4a90e2;
    background: rgba(0, 0, 0, 0.3);
}

.modal-header h3 {
    color: #ffd700;
    font-size: 20px;
    text-shadow: 0 0 8px #ffd700;
}

.close {
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #ff6b6b;
}

.help-content {
    padding: 20px;
    color: white;
    line-height: 1.6;
}

.help-content p {
    margin-bottom: 12px;
}

.help-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.help-content li {
    margin-bottom: 6px;
}

.leaderboard-list {
    padding: 20px;
    color: white;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border-left: 4px solid #4a90e2;
}

.leaderboard-entry.top-score {
    border-left-color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
}

/* Power-up notification */
.power-up-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #ffd700, #ffed4a);
    color: #1a1a4a;
    font-size: 20px;
    font-weight: bold;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    animation: powerUpPulse 2s ease-in-out;
    z-index: 5;
    pointer-events: none;
}

@keyframes powerUpPulse {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* Mobile controls */
.mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    pointer-events: auto;
    z-index: 3;
}

.touch-area {
    width: 100%;
    height: 100%;
    background: rgba(74, 144, 226, 0.1);
    border-top: 2px solid rgba(74, 144, 226, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.touch-hint {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    text-align: center;
    pointer-events: none;
}

/* Hide mobile controls on desktop */
@media (min-width: 768px) {
    .mobile-controls {
        display: none;
    }
}

/* Mobile optimizations */
@media (max-width: 767px) {
    .status-bar {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .question-panel {
        top: 50px;
        padding: 8px 16px;
    }
    
    .question-text {
        font-size: 16px;
    }
    
    .question-meaning {
        font-size: 12px;
    }
    
    .control-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .game-over-content {
        padding: 20px;
        margin: 16px;
    }
    
    .modal-content {
        margin: 16px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .game-container {
        border: 3px solid white;
    }
    
    .status-bar {
        background: black;
        border-bottom-color: white;
    }
    
    .question-panel {
        background: black;
        border-color: white;
    }
}